package com.rc.rc_exam.entity.web;



public class Result<T> {

    private Integer code;

    private String message;

    private T data;

    public static <T> Result<T> ok(){
        Result<T> result = new Result<>();
        result.setCode(200);
        result.setMessage("success");
        return result;
    }

    public static <T> Result<T> ok(String msg){
        Result<T> result = new Result<T>();
        result.setCode(200);
        result.setMessage(msg);
        return result;
    }

    public static <T> Result<T> ok(T data){
        Result<T> result = new Result<T>();
        result.setCode(200);
        result.setMessage("success");
        result.setData(data);
        return result;
    }

    public static <T> Result<T> error(String msg){
        Result<T> result = new Result<T>();
        result.setCode(500);
        result.setMessage(msg);
        return result;
    }

    public static <T> Result<T> error(){
        Result<T> result = new Result<T>();
        result.setCode(500);
        result.setMessage("service error");
        return result;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}
